//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    /*  */
    userInfo_sj: {},
    /*  */
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    clicked_alert:false,
    clicked_service: false,
    /*  */
    menuData:[
      {
        name:'客户管理',
        hasJG:true,
        isFT:true,
        url:'/pages/customer/customer',
        src:'../../assets/images/index-icon1.png'
      },
      {
        name:'报案管理',
        hasJG:false,
        isFT:true,
        url:'/pages/alarm/alarm',
        src:'../../assets/images/index-icon2.png'
      },
      {
        name:'维修管理',
        hasJG:true,
        isFT:false,
        url:'/pages/repair/repair',
        src:'../../assets/images/index-icon3.png'
      },
      {
        name:'预约管理',
        hasJG:false,
        isFT:false,
        url:'/pages/appointment/appointment',
        src:'../../assets/images/index-icon4.png'
      }
    ],
    /*  */
    hasMobile:''
  },
  /*  */
  setNeedAnimation: function(e){
    let { info, index } = e.currentTarget.dataset
    return app.globalData.setNeedAnimation.call(this,'menuData',this.data.menuData,index).then(()=>{
      //
      if(!this.data.userInfo_sj.mobile){
        wx.switchTab({
          url: '/pages/personal/personal',
        })
        return
      }
      //
      wx.navigateTo({
        url:''+info.url,
        success: res=>{
          res.eventChannel.emit('show-menu-item-page',{
            path:info.url
          })
        }
      })
    })
  },
  onShow: function(){
    //获取用户信息
    this.setData({
      userInfo_sj: app.globalData.get_userInfo()
    })
    console.log(this.data.userInfo_sj)
  },
  onLoad: function () {
    
  }
})
